<html>
<head>
    <title><?php echo $title; ?></title>
    <meta charset="utf-8"/>
    <script src="http://code.jquery.com/jquery-1.10.2.js"></script>
    <script>
        $(document).ready(function(){
            $("#check_all").click(function(){
                $('input:checkbox').not(this).prop('checked', this.checked);
            });

            $( "." ).click(function() {
                //alert( "Handler for .click() called." );
                if($(".check").is(":checked")){
                    window.location = "<?php echo base_url(); ?>index.php/admin/comment/checkShow";
                }else{
                    window.location = "<?php echo base_url(); ?>index.php/admin/comment";
                }
            });

        });
    </script>
</head>
<body>


<p class="bold">List Comment</p>
<form method="post" action="<?php echo base_url(); ?>admin/comment/checkShow">
<table width="750" >
    <tr class="title_table">
        <td>Stt</td>
        <td>Product</td>
        <td>Name</td>
        <td>Email</td>
        <td>Title</td>
        <td>Description</td>
        <td>Date</td>
        <td>Show</td>
        <td></td>
        <td></td>
        <td><input type="checkbox" name="check_all" id="check_all"></td>
    </tr>
    <?php if($comment != NULL){ ?>
        <?php $i=1; foreach($comment as $data){ ?>
            <tr>
                <td width="30"><?php echo $i; ?></td>
                <td width="80"><?php foreach ($nameproduct as $name) { ?>
                        <?php if ($data['product_id'] == $name['product_id']) { ?>
                            <?php echo $name['product_name']; ?>
                        <?php } ?> <?php } ?></td>
                <td width="70"><?php echo $data['comment_user_name']; ?></td>
                <td width="70"><?php $b =  str_split($data['comment_user_email'],15);
                    print_r($b[0]."...") ;
                    ?></td>
                <td width="70"><?php $b =  str_split($data['comment_title'],20);
                    print_r($b[0]."...") ;
                    ?></td>
                <td width="200"><?php $b =  str_split($data['comment_description'],30);
                    print_r($b[0]."...") ;
                    ?></td>
                <td width="80"><?php echo $data['comment_date']; ?></td>
                <td width="50" align="center"><p><?php if($data['comment_show'] == 1){ echo "Có";}else{ echo "Không";} ?></p></td>
                <td width="80"><a href="<?php echo base_url(); ?>index.php/admin/comment/detail/<?php echo $data['comment_id']; ?>">Chi tiết</a>
                </td>
                <td width="40"><a href="<?php echo base_url(); ?>index.php/admin/comment/del/<?php echo $data['comment_id']; ?>">Xóa</a>
                </td>
                <td width="30" align="center"><input type="checkbox" class="check" name="check[]" value="<?php echo $data['comment_id']; ?>"></td>
            </tr>
            <?php $i++;
        }
    } ?>
</table>
    <p><?php echo $this->pagination->create_links(); ?></p>
<input type="submit" id="show" class="show" name="show" value="Show/Hide">
<input type="submit" class="delete" name="delete" value="Delete">
</form>
</body>
</html>